//
//  Student.m
//  OCDay7homework
//
//  Created by dllo on 16/5/30.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "Student.h"

@implementation Student
@synthesize name = _name;
@synthesize sex = _sex;
@synthesize age = _age;

-(void)setName:(NSString *)name{
    if(_name != name){
        [name release];
        _name = [name retain];
    }
}

-(NSString *)name{
    return [[_name retain] autorelease];
}

-(void)setSex:(NSString *)sex{
    if(_sex != sex){
        [sex release];
        _sex = [sex copy];
    }
}

-(NSString *)sex{
    return [[_sex retain] autorelease];
}

-(instancetype)initWithName:(NSString *)name withSex:(NSString *)sex withAge:(NSInteger)age{
    self = [super init];
    if(self){
        self.name = name;
        self.sex = sex;
        self.age = age;
    }
    return self;
}

+(instancetype)studentWithName:(NSString *)name withSex:(NSString *)sex withAge:(NSInteger)age{
    Student *student = [[Student alloc] initWithName:name withSex:sex withAge:age];
    return [student autorelease];
}
@end
